import axios from 'axios'
import { getAuthToken } from './auth.js'

const request = axios.create({
  baseURL: 'http://127.0.0.1:8000/', // 根据后端实际地址调整
  timeout: 10000
})

// 请求拦截器，自动加token
request.interceptors.request.use(
  config => {
    const token = getAuthToken()
    if (token) {
      config.headers['Authorization'] = 'Bearer ' + token
    }
    return config
  },
  error => Promise.reject(error)
)

export default request 